/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.sorbonne.soa.lib;

import fr.sorbonne.soa.entity.Shipperinfo;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Nairo
 */
@Stateless
public class ShipperinfoFacade implements ShipperinfoFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(Shipperinfo shipperinfo) {
        em.persist(shipperinfo);
    }

    public void edit(Shipperinfo shipperinfo) {
        em.merge(shipperinfo);
    }

    public void remove(Shipperinfo shipperinfo) {
        em.remove(em.merge(shipperinfo));
    }

    public Shipperinfo find(Object id) {
        return em.find(Shipperinfo.class, id);
    }

    public List<Shipperinfo> findAll() {
        return em.createQuery("select object(o) from Shipperinfo as o").getResultList();
    }

    public List<Shipperinfo> findShipperByShippingConditions(String shippingConditions) {
        return em.createQuery("select object(o) from Shipperinfo as o.speciality = " + shippingConditions).getResultList();
    }

}
